<?php
session_start();
include "class.Validator.php";

$valid = new Validator();

if($_POST)
{
    if(isset($_POST['username']) && $_POST['username'])
    {
	if($valid->validUsername($_POST['username']))	
        {
            $_SESSION['username'] = $_POST['username'];
            header('Location: krok2.php');
        }
        else
        {
            $mess = 'Špatně zadané jméno';
        }
    }
    else
    {
        $mess = "Zadejte jméno."; 
    }
}

?>
<!DOCTYPE html>
<html>
<head>
<title>Úkol 8</title>
<meta charset="utf-8">
<style>
    body 
    {
        background: #0D48A7;
        font-family: Georgia, Times, serif;
        color: white;
    } 
    #body
    {
        background: #4079D3;
        min-width: 500px;
        width: 70%;
        position: relative;
        margin: 0px auto;
        text-align: center;
    }
    #header
    {
        background: #042D6D;
    }
    #footer
    {
        background: #042D6D;
    }
    table 
    {
        
        margin: 10px auto;
    }
    #menu a
    {
        color: white;
        margin-left: 2em
    } 
</style>
</head>
<body>
    <div id="body">
        <div id="header">
            <h1>WIZZARD</h1>    
        </div>
        <div id ="menu">
            <?php require 'menu.php'; ?>
        </div>
        <div id="content">
        	<h2>Aplikace pro výpočet opilosti</h2>
                <?php if($mess) echo "<p>".$mess."</p>"; ?>
        	<form method="post">
        		<table>
        			<tr>
        				<td><label for="username">Jméno</label></td>
        				<td><input type="text" name="username" id="username" ></td>
				</tr>
				<tr>
					<td colspan="2"><input type="submit" name="submit" value="Další"></td>
				</tr>
			</table>					
        	</form>
        </div>
        <div id="footer">
            <p>&not;&copy;&sup2; Petr Panoška</p>
        </div>
    </div>
</body>
</html>
